

install(DIRECTORY ${PROJECT_ROOT}/comn/ DESTINATION comn)
install(DIRECTORY ${PROJECT_ROOT}/DemoFile/ DESTINATION DemoFile)
install(DIRECTORY ${PROJECT_ROOT}/DemoUrl/ DESTINATION DemoUrl)
install(DIRECTORY ${PROJECT_ROOT}/DemoStream/ DESTINATION DemoStream)
install(DIRECTORY ${PROJECT_ROOT}/DemoWin/ DESTINATION DemoWin)

install(DIRECTORY ${PROJECT_ROOT}/cmake/ DESTINATION cmake)

install(DIRECTORY ${THIRD_PARTY}/ffmpeg/ DESTINATION third_party/ffmpeg)
install(DIRECTORY ${THIRD_PARTY}/SDL2/ DESTINATION third_party/SDL2)

install(FILES ${PROJECT_ROOT}/setup/CMakeLists.txt DESTINATION .)


if(WIN32)
	install(DIRECTORY ${THIRD_PARTY}/ffmpeg/bin/ DESTINATION bin FILES_MATCHING PATTERN "*.exe")
	
	install(DIRECTORY ${THIRD_PARTY}/ffmpeg/bin/ DESTINATION lib FILES_MATCHING PATTERN "*.dll")
	install(DIRECTORY ${THIRD_PARTY}/SDL2/lib/x86/ DESTINATION lib FILES_MATCHING PATTERN "*.dll")

else()
	install(DIRECTORY ${THIRD_PARTY}/ffmpeg/linux/lib/ DESTINATION lib FILES_MATCHING PATTERN "lib*")
	install(FILES ${THIRD_PARTY}/SDL2/lib/libSDL2.so DESTINATION lib)
	install(FILES ${THIRD_PARTY}/SDL2/lib/libSDL2.so DESTINATION lib RENAME libSDL2-2.0.so.0)
	
endif()

set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .)
#include(InstallRequiredSystemLibraries)

#set(CPACK_PACKAGE_DIRECTORY ${PROJECT_ROOT})
set(CPACK_PACKAGE_NAME "MediaDecoder")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "media decoder")
set(CPACK_PACKAGE_VENDOR "www.100wits.com")
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH "21")

if(UNIX)
	SET(CPACK_GENERATOR "TGZ")
else()
	SET(CPACK_GENERATOR "ZIP")
endif()

set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/dist")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") 

include(CPack)